import {
	ref
} from "vue";
import {
	post
} from "/common/api.js"
import {
	onShow
} from "@dcloudio/uni-app";
import { brandStories } from "../data/brand/story.js";

export function useData(functionMethod, searchObject) {
	//集合
	let modelData = ref({})

	onShow(async () => {
		// 如果是品牌故事接口，直接返回模拟数据
		if (functionMethod === "/brand/story") {
			modelData.value = brandStories[0]; // 返回第一条故事数据
			return;
		}
		
		let res = await post(functionMethod, searchObject.value);
		if (res.code !== 200) {
			return;
		}
		modelData.value = res.data;
	})
	return {
		modelData
	}
}